package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/1/28 15:56
 * @since v1.0
 */
@Getter
public enum WorkOrderMenuEnum {


    //工单
    WORK_ORDER(XbbRefTypeEnum.WORK_ORDER.getI18nName(), XbbRefTypeEnum.WORK_ORDER.getAlias(), XbbRefTypeEnum.WORK_ORDER.getCode(), AccessLinkEnum.WORK_ORDER, "", MenuTypeEnum.FORM.getType()),;
    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;
    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;

    WorkOrderMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type){
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static WorkOrderMenuEnum getByAlias(String alias) {
        for (WorkOrderMenuEnum workOrderMenuEnum : values()) {
            if (workOrderMenuEnum.getAlias().equals(alias)) {
                return workOrderMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
